package lab4_4;

class Account {
	private int balance;

	public Account(int balance) {
		super();
		this.balance = balance;
	}

	public int getBalance() {
		return balance;
	}

	public synchronized void deposit(int money) {

		this.balance = getBalance() + money;

	}

	public synchronized void withdraw(int money) {
		this.balance = getBalance() - money;

		try {
			if (balance < 0) {
				wait();

			}
			notify();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (balance < 0) {
		
			throw new IllegalStateException(balance + "");

		}
	}
}

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
